<?php
namespace app\service;
use alipay\AopClient;
use alipay\AlipayEcoCplifeCommunityCreateRequest;    //添加小区信息
use alipay\AlipayOpenAuthTokenAppRequest;    //查询物业token
use alipay\AlipayEcoCplifeCommunityBatchqueryRequest;    //查询小区信息
use alipay\AlipayEcoCplifeCommunityModifyRequest;    //修改小区信息
use alipay\AlipayEcoCplifeCommunityDetailsQueryRequest;    //查询单个物业小区信息
use alipay\AlipayEcoCplifeRoominfoUploadRequest;    //添加小区房屋信息
use alipay\AlipayEcoCplifeRoominfoQueryRequest;    //查询小区房屋信息
use alipay\AlipayEcoCplifeRoominfoDeleteRequest;    //删除小区房屋信息
use alipay\AlipayEcoCplifeBasicserviceInitializeRequest;     //初始化小区
use alipay\AlipayEcoCplifeBasicserviceModifyRequest;        //修改小区基本服务信息
use alipay\AlipayEcoCplifeBillBatchqueryRequest;        //查询房屋账单信息
use alipay\AlipayEcoCplifeBillBatchUploadRequest;       //上传房屋账单
use alipay\AlipayEcoCplifeBillModifyRequest;        //修改已上传的物业费账单数据
use alipay\AlipayEcoCplifeBillDeleteRequest;        //删除已上传的物业费账单数据

use alipay\AlipaySystemOauthTokenRequest;//换取授权访问令牌
use alipay\AlipayTradeCreateRequest;//生成订单
use alipay\AlipayTradeCloseRequest;
use think\Db;
class apiService{
    const PRIKEYPATH = '/www/wwwroot/zaozao/prikey.txt';//私钥路径
    const PUBKEYPATH = '/www/wwwroot/zaozao/pubkey.txt';//支付宝公钥路径
    // const PUBLICKEYPATH = 'C:\phpStudy\WWW\anran\public.txt';//应用公钥路径
    const XCXPRIKEYPATH = '/www/wwwroot/zaozao/xcxprikey.txt';//私钥路径
    const XCXPUBKEYPATH = '/www/wwwroot/zaozao/xcxpubkey.txt';//支付宝公钥路径

    private $app_id;//支付宝分配给开发者的应用
    private $method;//接口名称
    private $format;//仅支持JSON  no
    private $charset = 'UTF-8';//请求使用的编码格式，如utf-8,gbk,gb2312等
    private $sign_type = 'RSA2';//商户生成签名字符串所使用的签名算法类型，目前支持RSA2和RSA，推荐使用RSA2
    private $sign;//商户请求参数的签名串  no
    private $timestamp;//发送请求的时间，格式"yyyy-MM-dd HH:mm:ss"
    private $version = '1.0';//调用的接口版本，固定为：1.0
    private $app_auth_token;//详见应用授权概述 no
    private $biz_content;//请求参数的集合，最大长度不限，除公共参数外所有请求参数都必须放在这个参数中传递，具体参照各产品快速接入文档
    private $community_name;//小区名称，最长不超过32个字符。
    private $community_address;//小区主要详细地址，不需要包含省市区名称。
    private $district_code;//区县编码
    private $city_code;//地级市编码
    private $province_code;//省份编码
    private $community_locations;//小区所在的经纬度
    private $associated_pois;//若开发者录入的物业小区需要精确对应地图上多个小区  no
    private $hotline;//需要提供物业服务热线或联系电话，便于用户在需要时联系物业。
    private $out_community_id;//小区在物业系统中的唯一编号  no
    private $apiUrl; // no

    public function __construct($method, $apiUrl) {
        $this->app_id = config('app')['app_id'];
        $this->method = $method;
        $this->apiUrl = $apiUrl;
    }
    public function getPublicContent() {
        $prikey = file_get_contents(self::PRIKEYPATH);//私钥路径
        $pubkey = file_get_contents(self::PUBKEYPATH);//支付宝公钥路径
        // $publickey = file_get_contents(self::PUBLICKEYPATH);//应用公钥路径

        $aop = new AopClient ();
        $aop->gatewayUrl = $this->apiUrl;
        $aop->appId = $this->app_id;
        $aop->rsaPrivateKey = $prikey;
        $aop->alipayrsaPublicKey= $pubkey;
        // $aop->alipayPublicKey= $publickey;
        $aop->apiVersion = $this->version;
        $aop->signType = $this->sign_type;
        $aop->postCharset= $this->charset;
        $aop->format='json';

        return $aop;
    }
    
    public function getAppAuthToken($code) {
        $aop = $this->getPublicContent();
        $request = new AlipayOpenAuthTokenAppRequest();
        $request->setBizContent("{" .
            "    \"grant_type\":\"authorization_code\"," .
            "    \"code\":\"$code\"" .
            "  }");
        $response = $aop->execute($request);
        dump($response);exit();
    }

    //XIOA
    public function xcxgetPublicContent(){
        $aop = new AopClient ();
        $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
        $aop->appId = '2018110562021261';
        $aop->rsaPrivateKey = file_get_contents(self::XCXPRIKEYPATH);//私钥路径
        $aop->alipayrsaPublicKey= file_get_contents(self::XCXPUBKEYPATH);//支付宝公钥路径
        $aop->apiVersion = '1.0';
        $aop->signType = 'RSA2';
        $aop->postCharset='UTF-8';
        $aop->format='json';
        return $aop;
    }

    //小程序换取授权访问令牌
    public function xcxoauthToken($code){
        $aop = $this->xcxgetPublicContent();
        $request = new AlipaySystemOauthTokenRequest ();
        $request->setGrantType("authorization_code");
        $request->setCode($code);
        $request->setRefreshToken('');
        $result = $aop->execute ($request);
        if(property_exists($result,'error_response')){
            $responseNode = 'error_response';
        }else{
            $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";   
        }
        return $result->$responseNode;
    }

    //添加小区信息
    public function create($data) {
        $data = json_decode($data);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeCommunityCreateRequest ();
        $request->setBizContent("{" .
        "\"community_name\":\"$data->community_name\"," .
        "\"community_address\":\"$data->community_address\"," .
        "\"district_code\":\"$data->district_code\"," .
        "\"city_code\":\"$data->city_code\"," .
        "\"province_code\":\"$data->province_code\"," .
        "      \"community_locations\":[" .
        "        \"$data->community_locations\"" .
        "      ]," .
        "      \"associated_pois\":[" .
        // "        \"$this->associated_pois\",\"$this->associated_pois\"" .
        "      ]," .
        "\"hotline\":\"$data->hotline\"," .
        "\"out_community_id\":\"\"" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ($request, null, $token); 
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return $result->$responseNode->community_id;
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }    
    }

    //查询小区编号
    public function fetchCommunityId($token) {
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeCommunityBatchqueryRequest ();
        $request->setBizContent("{" .
        "\"status\":\"PENDING_ONLINE\"," .
        "\"page_num\":1," .
        "\"page_size\":500" .
        "  }");
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }

    //变更小区信息
    public function update($data) {
        $data = json_decode($data);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeCommunityModifyRequest ();//
        $request->setBizContent("{" .
        "\"community_id\":\"$data->community_id\"," .
        "\"community_name\":\"$data->community_name\"," .
        "\"community_address\":\"$data->community_address\"," .
        "\"district_code\":\"$data->district_code\"," .
        "\"city_code\":\"$data->city_code\"," .
        "\"province_code\":\"$data->province_code\"," .
        "      \"community_locations\":[" .
        "        \"$data->community_locations\"" .
        "      ]," .
        "      \"associated_pois\":[" .
        "      ]," .
        "\"hotline\":\"$data->hotline\"," .
        "\"out_community_id\":\"\"" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return isset($result->$responseNode->community_id) ? ['community_id' => $result->$responseNode->community_id] : true;
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }

    //查询单个物业小区信息
    public function fecthCommunityByCommunityId($community_id,$token) {
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeCommunityDetailsQueryRequest ();
        $request->setBizContent("{" .
        "\"community_id\":\"$community_id\"" .
        "  }");
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        // dump($result->$responseNode);exit();
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->msg];
        }
    }

    //初始化小区
    public function initialize($data){
        $data = json_decode($data);
        // $alipayLoginId = is_null($data->account) ? $data->account : '';
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBasicserviceInitializeRequest ();
        $request->setBizContent("{" .
        "\"community_id\":\"$data->community_id\"," .
        "\"service_type\":\"PROPERTY_PAY_BILL_MODE\"," .
        "\"external_invoke_address\":\"$data->external_invoke_address\"," .
        "\"account_type\":\"ALIPAY_PARTNER_ID\"," .
        "\"account\":\"$data->account\"," .
        "\"service_expires\":\"2018-12-31 23:59:59\"" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        // dump($result->$responseNode);exit();
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode->next_action];
        } else {
            return ['error' => $result->$responseNode->msg];
        }
    }

    //修改小区状态
    public function basicservice($data){
        $data = json_decode($data);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBasicserviceModifyRequest ();
        $request->setBizContent("{" .
        "\"community_id\":\"$data->community_id\"," .
        "\"service_type\":\"PROPERTY_PAY_BILL_MODE\"," .
        "\"status\":\"ONLINE\"," .
        "\"external_invoke_address\":\"$data->external_invoke_address\"," .
        "\"account_type\":\"ALIPAY_PARTNER_ID\"," .
        "\"account\":\"$data->account\"," .
        "\"service_expires\":\"2018-12-31 23:59:59\"" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;

        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' =>  $result->$responseNode->msg];
        }
    }

    //添加小区房屋信息
    public function addRoom($data){
        $data = json_decode($data);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeRoominfoUploadRequest ();
        $request->setBizContent("{" .
        "\"batch_id\":\"$data->batch_id\"," .
        "\"community_id\":\"$data->community_id\"," .
        "      \"room_info_set\":[{" .
        "        \"out_room_id\":\"$data->out_room_id\"," .
        "\"group\":\"$data->group\"," .
        "\"building\":\"$data->building\"," .
        "\"unit\":\"$data->unit\"," .
        "\"room\":\"$data->room\"," .
        "\"address\":\"$data->address\"" .
        "        }]" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }
    
    //添加小区房屋信息
    public function addRoom2($data,$roomlist){
        $data = json_decode($data);
        $roomlist= json_decode($roomlist);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeRoominfoUploadRequest ();
        $str="";
        foreach($roomlist as $roominfo){
            $building=$roominfo->building."幢";
            $unit=$roominfo->unit."单元";
            $room=$roominfo->room."室";
            $str=$str."{" .
                "        \"out_room_id\":\"$roominfo->out_room_id\"," .
                "\"group\":\"$roominfo->group\"," .
                "\"building\":\"$building\"," .
                "\"unit\":\"$unit\"," .
                "\"room\":\"$room\"," .
                "\"address\":\"$roominfo->address\"" .
                "        },";
        }
        $str=substr($str,0,strlen($str)-1);
        //return $str;
        $request->setBizContent("{" .
        "\"batch_id\":\"$data->batch_id\"," .
        "\"community_id\":\"$data->community_id\"," .
        "      \"room_info_set\":[".$str."]" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }
    
    //删除小区房屋信息
    public function delRoom($data){
        $data = json_decode($data);
        if (strpos($data->out_room_id, ',')) {
            $arr = explode(',', $data->out_room_id);
            $str = '';
            $str = '[';
            foreach ($arr as $val) {
                $str .= '"' . $val . '",';
            }
            $str .= ']';
            $data->out_room_id = $str;
        }else{
            $data->out_room_id = "[\"$data->out_room_id\"]";
        }
        // return ['error' => $data];
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeRoominfoDeleteRequest ();
        $request->setBizContent("{" .
        "\"batch_id\":\"$data->batch_id\"," .
        "\"community_id\":\"$data->community_id\"," .
        "      \"out_room_id_set\":$data->out_room_id".
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode->code];
        }else{
            return ['error' => $result->$responseNode->msg];
        }
    }
     //删除小区房屋信息
    public function delRoom2($data,$roomlist){
        $data = json_decode($data);
        $roomlist=json_decode($roomlist);
        $out_room_id = '[';
        foreach ($roomlist as $roominfo){
            $out_room_id = $out_room_id.'"' .$roominfo->out_room_id . '",';
        }
        
        $out_room_id=substr($out_room_id,0,strlen($out_room_id)-1);
        $out_room_id=$out_room_id.']';
        //return $str;
        
        // return ['error' => $data];
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeRoominfoDeleteRequest ();
        $request->setBizContent("{" .
        "\"batch_id\":\"$data->batch_id\"," .
        "\"community_id\":\"$data->community_id\"," .
        "      \"out_room_id_set\":$out_room_id".
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode->code];
        }else{
            return ['error' => $result->$responseNode->msg];
        }
    }
    
    //查询小区房屋信息
    public function listRoom($community_id,$token,$page){
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeRoominfoQueryRequest();
        $request->setBizContent("{" .
        "\"community_id\":\"$community_id\"," .
        "\"page_num\":\"$page\"," .
        "\"page_size\":500" .
        "  }");
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        //return $result;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }
    //查询房屋账单
    public function roomBillList($data){
        $data = json_decode($data);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBillBatchqueryRequest ();
        $request->setBizContent("{" .
        "\"community_id\":\"$data->community_id\"," .
        "\"bill_status\":\"$data->bill_status\"," .
        "\"out_room_id\":\"$data->out_room_id\"," .
        "\"cost_type\":\"$data->cost_type\"," .
        "\"acct_period\":\"$data->acct_period\"," .
        "\"release_day\":\"$data->release_day\"," .
        "\"batch_id\":\"$data->batch_id\"," .
        "\"page_num\":1," .
        "\"page_size\":500" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token);
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }

    //上传房屋账单
    public function roomBillAdd($data){
        $data = json_decode($data);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBillBatchUploadRequest ();
        $request->setBizContent("{" .
        "\"batch_id\":\"$data->batch_id\"," .
        "\"community_id\":\"$data->community_id\"," .
        "      \"bill_set\":[{" .
        "        \"bill_entry_id\":\"$data->bill_entry_id\"," .
        "\"out_room_id\":\"$data->out_room_id\"," .
        "\"room_address\":\"$data->room_address\"," .
        "\"cost_type\":\"$data->cost_type\"," .
        "\"bill_entry_amount\":\"$data->bill_entry_amount\"," .
        "\"acct_period\":\"$data->acct_period\"," .
        "\"release_day\":\"$data->release_day\"," .
        "\"deadline\":\"$data->deadline\"," .
        "\"relate_id\":\"\"," .
        "\"remark_str\":\"$data->remark_str\"" .
        "        }]" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token);  
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }
    //批量上传房屋账单
    public function roomBillAdd2($data,$billlist){
        $data = json_decode($data);
        $billlist = json_decode($billlist);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBillBatchUploadRequest ();
        $billset="";
        foreach($billlist as $billinfo){
            $roominfo=Db::table("roominfo")
                    ->where("out_room_id",$billinfo->out_room_id)
                    ->where("community_id",$billinfo->community_id)
                    ->find();
            $owner_name=$roominfo["owner_name"];
            $billset=$billset."{" .
            "        \"bill_entry_id\":\"$billinfo->bill_entry_id\"," .
            "\"out_room_id\":\"$billinfo->out_room_id\"," .
            "\"room_address\":\"$billinfo->room_address\"," .
            "\"cost_type\":\"$billinfo->cost_type\"," .
            "\"bill_entry_amount\":\"$billinfo->bill_entry_amount\"," .
            "\"acct_period\":\"$billinfo->acct_period\"," .
            "\"release_day\":\"$billinfo->release_day\"," .
            "\"deadline\":\"$billinfo->deadline\"," .
            "\"relate_id\":\"\"," .
            "\"remark_str\":\"$owner_name\"" .
            "        },";
        }
        $billset=substr($billset,0,strlen($billset)-1);
        //return $billset;
        
        $request->setBizContent("{" .
        "\"batch_id\":\"$data->batch_id\"," .
        "\"community_id\":\"$data->community_id\"," .
        "      \"bill_set\":[".$billset."]" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token);  
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }

    //修改账单信息
    public function roomBillEdit($data){
        $data = json_decode($data);
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBillModifyRequest ();
        $request->setBizContent("{" .
        "\"community_id\":\"$data->community_id\"," .
        "      \"bill_entry_list\":[{" .
        "        \"bill_entry_id\":\"$data->bill_entry_id\"," .
        "\"room_address\":\"$data->room_address\"," .
        "\"cost_type\":\"$data->cost_type\"," .
        "\"bill_entry_amount\":\"$data->bill_entry_amount\"," .
        "\"acct_period\":\"$data->acct_period\"," .
        "\"release_day\":\"$data->release_day\"," .
        "\"deadline\":\"$data->deadline\"" .
        "        }]" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }

    //删除账单信息
    public function roomBillDel($data){
        $data = json_decode($data);
        if (strpos($data->bill_entry_id, ',')) {
            $arr = explode(',', $data->bill_entry_id);
            $str = '';
            $str = '[';
            foreach ($arr as $val) {
                $str .= '"' . $val . '",';
            }
            $str .= ']';
            $data->bill_entry_id = $str;
        }else{
            $data->bill_entry_id = "[\"$data->bill_entry_id\"]";
        }
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBillDeleteRequest ();
        $request->setBizContent("{" .
        "\"community_id\":\"$data->community_id\"," .
        "      \"bill_entry_id_list\":$data->bill_entry_id" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }
    //批量删除账单信息
    public function roomBillDel2($data,$billlist){
        $data = json_decode($data);
        $billlist=json_decode($billlist);
        $bill_entry_id='[';
        foreach ($billlist as $billinfo){
            $bill_entry_id=$bill_entry_id.'"' . $billinfo->bill_entry_id . '",';
        }
        $bill_entry_id=substr($bill_entry_id,0,strlen($bill_entry_id)-1);
        $bill_entry_id=$bill_entry_id.']';
        
        $aop = $this->getPublicContent();
        $request = new AlipayEcoCplifeBillDeleteRequest ();
        $request->setBizContent("{" .
        "\"community_id\":\"$data->community_id\"," .
        "      \"bill_entry_id_list\":$bill_entry_id" .
        "  }");
        $token = $data->token;
        $result = $aop->execute ( $request, null, $token); 
        
        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
            return ['success' => $result->$responseNode];
        } else {
            return ['error' => $result->$responseNode->sub_msg];
        }
    }
}